﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AbpDemo.Migrations
{
    public partial class rbac : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "HotelMenu",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    MenuType = table.Column<int>(type: "int", nullable: false),
                    MenuName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ApiPath = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RouteName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RoutePath = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    ComponentPath = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Redirect = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    IsHidden = table.Column<bool>(type: "bit", nullable: false),
                    Icon = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotelMenu", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HotelRole",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleNames = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotelRole", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HotelAdminRole",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AdminId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotelAdminRole", x => x.Id);
                    table.ForeignKey(
                        name: "FK_HotelAdminRole_HotelAdmin_AdminId",
                        column: x => x.AdminId,
                        principalTable: "HotelAdmin",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_HotelAdminRole_HotelRole_RoleId",
                        column: x => x.RoleId,
                        principalTable: "HotelRole",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "HotelRoleMenu",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    MenuId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotelRoleMenu", x => x.Id);
                    table.ForeignKey(
                        name: "FK_HotelRoleMenu_HotelMenu_MenuId",
                        column: x => x.MenuId,
                        principalTable: "HotelMenu",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_HotelRoleMenu_HotelRole_RoleId",
                        column: x => x.RoleId,
                        principalTable: "HotelRole",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_HotelAdminRole_AdminId",
                table: "HotelAdminRole",
                column: "AdminId");

            migrationBuilder.CreateIndex(
                name: "IX_HotelAdminRole_RoleId",
                table: "HotelAdminRole",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_HotelRoleMenu_MenuId",
                table: "HotelRoleMenu",
                column: "MenuId");

            migrationBuilder.CreateIndex(
                name: "IX_HotelRoleMenu_RoleId",
                table: "HotelRoleMenu",
                column: "RoleId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "HotelAdminRole");

            migrationBuilder.DropTable(
                name: "HotelRoleMenu");

            migrationBuilder.DropTable(
                name: "HotelMenu");

            migrationBuilder.DropTable(
                name: "HotelRole");
        }
    }
}
